package com.mew.user.events;

import com.mew.user.events.service.DaysService;
import com.mew.common.exception.ResponseCode;
import com.mew.common.rest.events.DaysGetResponseMessage;
import com.mew.common.rest.events.DaysInfoResponseMessage;
import com.mew.common.rest.events.DaysRouletteResponseMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Date 2020/10/21 0021
 **/
@RestController
@Slf4j
public class DaysController {

    @Autowired
    private DaysService daysService;

    @GetMapping(value = "/days/info/{uid}")
    @ResponseBody
    public DaysInfoResponseMessage daysInf(@PathVariable("uid") long uid){
     try {
         return daysService.daysInf(uid);
     }catch (Exception e){
         log.error("daysInfo error uid: "+uid, e);
         return DaysInfoResponseMessage.builder().build().buildByResponseCode(ResponseCode.SysException);
     }

    }

    @GetMapping(value = "/days/get/{uid}/{gtype}")
    @ResponseBody
    public DaysGetResponseMessage daysGet(@PathVariable("uid") long uid, @PathVariable("gtype") int gtype){
     try {
         return daysService.daysGet(uid, gtype);
     }catch (Exception e){
         log.error("daysGet error uid: "+uid, e);
         return DaysGetResponseMessage.builder().build().buildByResponseCode(ResponseCode.SysException);
     }

    }


    @GetMapping(value = "/days/roulette/{uid}")
    @ResponseBody
    public DaysRouletteResponseMessage daysRoulette(@PathVariable("uid") long uid){
        try {
            return daysService.daysRoulette(uid);
        }catch (Exception e){
            log.error("daysRoulette error uid: "+uid, e);
            return DaysRouletteResponseMessage.builder().build().buildByResponseCode(ResponseCode.SysException);
        }

    }


}
